//
//  WdVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/7.
//

import Foundation

extension WdVC {
    
    func initUI() {
        
        let top_view = UIImageView()
        top_view.image = UIImage(named: "table2")
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(200)
        }
        
        tx = UIImageView.init(image: #imageLiteral(resourceName: "zhinneg@1.5x"))
        tx.backgroundColor = UIColor.init(lgf_HexString: "F1F2F4")
        tx.clipsToBounds = true
        tx.layer.cornerRadius = 27
        top_view.addSubview(tx)
        tx.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(17)
            make.centerY.equalToSuperview().multipliedBy(0.75)
            make.width.height.equalTo(54)
        }
        
        mz = UILabel.init()
        mz.text = "来国锋"
        mz.textColor = UIColor.white
        mz.font = UIFont.boldSystemFont(ofSize: 20)
        top_view.addSubview(mz)
        mz.snp.makeConstraints { (make) in
            make.left.equalTo(tx.snp.right).offset(15)
            make.centerY.equalTo(tx)
        }
        
        let dj = UIImageView.init(image: #imageLiteral(resourceName: "zhinneg@1.5x"))
        top_view.addSubview(dj)
        dj.snp.makeConstraints { (make) in
            make.left.equalTo(mz.snp.right).offset(5)
            make.centerY.equalTo(tx)
            make.width.height.equalTo(18)
        }
        
        let xb = UIImageView.init(image: #imageLiteral(resourceName: "zhuanhuan@1.5x"))
        top_view.addSubview(xb)
        xb.snp.makeConstraints { (make) in
            make.left.equalTo(dj.snp.right).offset(5)
            make.centerY.equalTo(tx)
            make.width.height.equalTo(18)
        }
        
        let sz_b = UIView.init()
        sz_b.isUserInteractionEnabled = true
        sz_b.lgf_AddTap(target: self, action: #selector(WdVC.shezhi(_:)))
        top_view.addSubview(sz_b)
        sz_b.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.centerY.equalTo(tx)
            make.width.height.equalTo(60)
        }
        let sz = UIImageView.init(image: #imageLiteral(resourceName: "shezhi@1.5x"))
        sz_b.addSubview(sz)
        sz.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(20)
            make.height.equalTo(22)
        }
        
//        let bzsl = UILabel.init()
//        bzsl.text = "1000"
//        bzsl.textColor = UIColor.white
//        bzsl.font = UIFont.boldSystemFont(ofSize: 20)
//        top_view.addSubview(bzsl)
//        bzsl.snp.makeConstraints { (make) in
//            make.centerY.equalToSuperview().multipliedBy(1.5).offset(-20)
//            make.centerX.equalToSuperview().multipliedBy(0.4)
//        }
//        let bzsl_z = UILabel.init()
//        bzsl_z.text = "标注数量"
//        bzsl_z.textColor = UIColor.white
//        bzsl_z.font = UIFont.systemFont(ofSize: 14)
//        top_view.addSubview(bzsl_z)
//        bzsl_z.snp.makeConstraints { (make) in
//            make.top.equalTo(bzsl.snp.bottom).offset(6)
//            make.centerX.equalToSuperview().multipliedBy(0.4)
//        }
//        
//        let scsl = UILabel.init()
//        scsl.text = "1000"
//        scsl.textColor = UIColor.white
//        scsl.font = UIFont.boldSystemFont(ofSize: 20)
//        top_view.addSubview(scsl)
//        scsl.snp.makeConstraints { (make) in
//            make.centerY.equalToSuperview().multipliedBy(1.5).offset(-20)
//            make.centerX.equalToSuperview().multipliedBy(1.0)
//        }
//        let scsl_z = UILabel.init()
//        scsl_z.text = "上传数量"
//        scsl_z.textColor = UIColor.white
//        scsl_z.font = UIFont.systemFont(ofSize: 14)
//        top_view.addSubview(scsl_z)
//        scsl_z.snp.makeConstraints { (make) in
//            make.top.equalTo(bzsl.snp.bottom).offset(6)
//            make.centerX.equalToSuperview().multipliedBy(1.0)
//        }
//        
//        let syrw = UILabel.init()
//        syrw.text = "1000"
//        syrw.textColor = UIColor.white
//        syrw.font = UIFont.boldSystemFont(ofSize: 20)
//        top_view.addSubview(syrw)
//        syrw.snp.makeConstraints { (make) in
//            make.centerY.equalToSuperview().multipliedBy(1.5).offset(-20)
//            make.centerX.equalToSuperview().multipliedBy(1.6)
//        }
//        let syrw_z = UILabel.init()
//        syrw_z.text = "剩余任务"
//        syrw_z.textColor = UIColor.white
//        syrw_z.font = UIFont.systemFont(ofSize: 14)
//        top_view.addSubview(syrw_z)
//        syrw_z.snp.makeConstraints { (make) in
//            make.top.equalTo(bzsl.snp.bottom).offset(6)
//            make.centerX.equalToSuperview().multipliedBy(1.6)
//        }
        
        let tj = LGFLoginImageTitleView.init(nil, nil, left: 0, placeholder: "", text: "统计", true)
        tj.lgf_ViewName = "统计"
        tj.delegate = self
        view.addSubview(tj)
        tj.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.equalTo(top_view.snp.bottom)
            make.height.equalTo(0)
        }
        
//        let bdjl = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "本地记录", true)
//        bdjl.lgf_ViewName = "本地记录"
//        bdjl.delegate = self
//        view.addSubview(bdjl)
//        bdjl.snp.makeConstraints { (make) in
//            make.left.equalToSuperview().offset(15)
//            make.right.equalToSuperview().offset(-15)
//            make.top.equalTo(tj.snp.bottom)
//            make.height.equalTo(44.lgf_H())
//        }
        
        let wtfk = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "问题反馈", true)
        wtfk.lgf_ViewName = "问题反馈"
        wtfk.delegate = self
        view.addSubview(wtfk)
        wtfk.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(15)
            make.right.equalToSuperview().offset(-15)
            make.top.equalTo(tj.snp.bottom)
            make.height.equalTo(44.lgf_H())
        }
        
        let logoutBtn = UIButton.init(type: .custom)
        logoutBtn.backgroundColor = UIColor.init(lgf_HexString: "DE6161")!
        logoutBtn.setTitle("退出登陆", for: .normal)
        logoutBtn.setTitleColor(EWEDarkMode.white(), for: .normal)
        logoutBtn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 15)
        logoutBtn.layer.cornerRadius = 8
        logoutBtn.layer.masksToBounds = true
        logoutBtn.addTarget(self, action: #selector(WdVC.logout(_:)), for: .touchUpInside)
        view.addSubview(logoutBtn)
        logoutBtn.snp.makeConstraints { (make) in
            make.top.equalTo(wtfk.snp.bottom).offset(100.lgf_H())
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().offset(-80.lgf_W())
            make.height.equalTo(44.lgf_H())
        }
    }

}

extension WdVC: LGFLoginImageTitleViewDelegate {
    func selectLGFLoginImageTitleView(_ view: LGFLoginImageTitleView) {
        self.view.endEditing(true)
        if view.lgf_ViewName == "问题反馈" {
            self.navigationController?.show(WtfkVC(), sender: self)
        } else if view.lgf_ViewName == "本地记录" {
            self.navigationController?.show(BdjlVC(), sender: self)
        } else if view.lgf_ViewName == "统计" {
            self.navigationController?.show(TjVC(), sender: self)
        }
    }
}
